package cc.yugu.yhdw.common.domain.hdw;

import cc.yugu.yhdw.common.constant.ConstEnum;
import cc.yugu.yhdw.common.domain.StringIdEntity;
import cc.yugu.yhdw.common.entity.json.DateTimeSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 换电订单
 */
public class ExchangeOrder extends StringIdEntity {

    public enum OrderStatus {
        INIT(1, "未付款"),
        PAY(2, "已付款"),
        OLD_BATTERY(3, "放入旧电"),
        COMPLETE(4, "完成"),
        CANCEL(5, "取消");

        private final int value;
        private final String name;

        private OrderStatus(int value, String name) {
            this.value = value;
            this.name = name;
        }

        private static Map<Integer, String> map = new HashMap<Integer, String>();

        static {
            for (OrderStatus e : OrderStatus.values()) {
                map.put(e.getValue(), e.getName());
            }
        }

        public static String getName(int value) {
            return map.get(value);
        }

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
    }

    public enum ErrorStatus {
        BATTERY_NOT_CUSTOMER(1, "请使用客户对应电池换电"),;

        private final int value;
        private final String name;

        private ErrorStatus(int value, String name) {
            this.value = value;
            this.name = name;
        }

        private static Map<Integer, String> map = new HashMap<Integer, String>();

        static {
            for (ErrorStatus e : ErrorStatus.values()) {
                map.put(e.getValue(), e.getName());
            }
        }

        public static String getName(int value) {
            return map.get(value);
        }

        public int getValue() {
            return value;
        }

        public String getName() {
            return name;
        }
    }

    Integer agentId;
    Integer agencyId;
    Integer price; //换电的价格
    Integer exchangeCharge; //用换电金额支付的钱
    Integer moneyCharge; //用金额支付的钱（换电支付金额）
    String cabinetId; //柜子
    String firstBoxNum;
    String secondBoxNum; //
    Date openFirstBoxTime;
    Date openSecondBoxTime;
    Date putFirstBatteryTime;
    Date takeSecondBatteryTime;
    String firstBatteryId;
    String secondBatteryId;
    String exchangePacketOrderId;
    Integer payType;
    Date payTime;
    Integer customerId;
    String customerMobile;
    Integer orderStatus;
    Integer errorStatus;
    Date createTime;
    int mileage;//

    public String getPayTypeName() {
        if (this.payType != null) {
            return ConstEnum.PayType.getName(this.payType);
        } else {
            return "";
        }
    }

    public String getExchangePacketOrderId() {
        return exchangePacketOrderId;
    }

    public void setExchangePacketOrderId(String exchangePacketOrderId) {
        this.exchangePacketOrderId = exchangePacketOrderId;
    }

    public Integer getErrorStatus() {
        return errorStatus;
    }

    public void setErrorStatus(Integer errorStatus) {
        this.errorStatus = errorStatus;
    }

    public int getMileage() {
        return mileage;
    }

    public void setMileage(int mileage) {
        this.mileage = mileage;
    }

    public Date getPutFirstBatteryTime() {
        return putFirstBatteryTime;
    }

    public void setPutFirstBatteryTime(Date putFirstBatteryTime) {
        this.putFirstBatteryTime = putFirstBatteryTime;
    }

    public Date getTakeSecondBatteryTime() {
        return takeSecondBatteryTime;
    }

    public void setTakeSecondBatteryTime(Date takeSecondBatteryTime) {
        this.takeSecondBatteryTime = takeSecondBatteryTime;
    }

    public Integer getMoneyCharge() {
        return moneyCharge;
    }

    public void setMoneyCharge(Integer moneyCharge) {
        this.moneyCharge = moneyCharge;
    }

    public Integer getExchangeCharge() {
        return exchangeCharge;
    }

    public void setExchangeCharge(Integer exchangeCharge) {
        this.exchangeCharge = exchangeCharge;
    }

    public Integer getAgentId() {
        return agentId;
    }

    public void setAgentId(Integer agentId) {
        this.agentId = agentId;
    }

    public Integer getAgencyId() {
        return agencyId;
    }

    public void setAgencyId(Integer agencyId) {
        this.agencyId = agencyId;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public String getCabinetId() {
        return cabinetId;
    }

    public void setCabinetId(String cabinetId) {
        this.cabinetId = cabinetId;
    }

    public String getFirstBoxNum() {
        return firstBoxNum;
    }

    public void setFirstBoxNum(String firstBoxNum) {
        this.firstBoxNum = firstBoxNum;
    }

    public String getFirstBatteryId() {
        return firstBatteryId;
    }

    public void setFirstBatteryId(String firstBatteryId) {
        this.firstBatteryId = firstBatteryId;
    }

    public String getSecondBatteryId() {
        return secondBatteryId;
    }

    public void setSecondBatteryId(String secondBatteryId) {
        this.secondBatteryId = secondBatteryId;
    }

    public String getSecondBoxNum() {
        return secondBoxNum;
    }

    public void setSecondBoxNum(String secondBoxNum) {
        this.secondBoxNum = secondBoxNum;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getOpenFirstBoxTime() {
        return openFirstBoxTime;
    }

    public void setOpenFirstBoxTime(Date openFirstBoxTime) {
        this.openFirstBoxTime = openFirstBoxTime;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getOpenSecondBoxTime() {
        return openSecondBoxTime;
    }

    public void setOpenSecondBoxTime(Date openSecondBoxTime) {
        this.openSecondBoxTime = openSecondBoxTime;
    }


    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getPayTime() {
        return payTime;
    }

    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public String getCustomerMobile() {
        return customerMobile;
    }

    public void setCustomerMobile(String customerMobile) {
        this.customerMobile = customerMobile;
    }

    public Integer getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(Integer orderStatus) {
        this.orderStatus = orderStatus;
    }

    @JsonSerialize(using = DateTimeSerializer.class)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getOrderStatusName() {
        return OrderStatus.getName(orderStatus);
    }
}
